package data
{
	import com.greensock.events.LoaderEvent;
	import com.greensock.loading.ImageLoader;
	
	import flash.display.Bitmap;

	public class Attraction
	{
		public var title:String;
		public var description:String;
		public var backgroundURL:String;
		public var attractionURL:String;
		
		public var image:Bitmap;
		
		public function Attraction()
		{
		}
		
		public function getImageLoader():ImageLoader
		{
			var imageLoader:ImageLoader = new ImageLoader(backgroundURL);
			
			imageLoader.addEventListener(LoaderEvent.COMPLETE,onImageLoadComplete);
			
			return imageLoader;
		}
		
		//listener methods
		private function onImageLoadComplete(e:LoaderEvent):void
		{
			var ldr:ImageLoader = ImageLoader(e.target);
			ldr.removeEventListener(LoaderEvent.COMPLETE,onImageLoadComplete);
			
			this.image = ldr.rawContent;				
			ldr = null;
		}
		
		//===============================
		public function toString():String
		{
			return "--->Attraction: " + title + " description: " + description + " backgroundURL: " + backgroundURL + " attractionURL: " + attractionURL +"\n";
		}
	}
}